﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cloud.Model;
using Cloud.BLL;


public partial class Three_Managerment_P0501_P_zhuanban : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {

            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            if (IsPostBack)
            {

            }
            else
            {
                this.bm_drop.DataSource = DWManager.Sanji(((USER_INFO)Session["users"]).DEPARTMENT);
                this.bm_drop.DataTextField = "DWMC";
                this.bm_drop.DataValueField = "DWBH";
                this.bm_drop.DataBind();
                int id = Convert.ToInt32(Request.QueryString["id"]);
                Problem_zhuanban activity = Problem_zhuanbanManager.FindById(id);
                this.sjid.Value = activity.Appealid.ToString();
                this.times.Value = activity.Regtime.ToString();
                int currentDay = Convert.ToInt32(DateTime.Now.DayOfWeek);
                if (currentDay == 6)
                {
                    this.xbsj.Value = DateTime.Now.AddDays(4).ToString();
                }
                else if (currentDay == 0 || currentDay == 1 || currentDay == 2)
                {
                    this.xbsj.Value = DateTime.Now.AddDays(3).ToString();
                }
                else
                {
                    this.xbsj.Value = DateTime.Now.AddDays(5).ToString();
                }
            }
        }
        catch (Exception ex)
        {

            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    protected void Send_Click(object sender, EventArgs e)
    {
        try
        {

            if (this.xbsj.Value.Equals(""))
            {
                Response.Write("<script>alert('请选择时间'); </script>");
                return;
            }


            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            int id = Convert.ToInt32(Request.QueryString["id"]);
            Problem_zhuanban activity = Problem_zhuanbanManager.FindById(Convert.ToInt32(Request.QueryString["id"]));
            activity.Current_ld = 2;
            activity.Bldwid = this.bm_drop.SelectedItem.Value;
            activity.Bm2_type = 0;
            activity.Zrdwid = ((USER_INFO)Session["users"]).DEPARTMENT;
            activity.Bm1_type = 2;
            activity.Handle_type = 0;
            activity.Xbtime = Convert.ToDateTime(xbsj.Value);
            if (Problem_zhuanbanManager.Update(activity) > 0)
            {
                Problem_historic2 his = new Problem_historic2();
                his.Blyj = this.con.Value;
                his.Title = ((USER_INFO)Session["users"]).USER_NAME + "  转派 ";
                his.Bm2 = bm_drop.SelectedItem.Value;
                his.Evente = 1;
                his.Idopen = this.sjid.Value;


                his.Bm1 = ((USER_INFO)Session["users"]).DEPARTMENT;
                his.Item1 = 0;
                his.Item2 = "";
                his.Item3 = "";
                his.Name = ((USER_INFO)Session["users"]).USER_NAME;
                his.Times = DateTime.Now;
                his.Timese = Convert.ToDateTime(xbsj.Value);
                // 04一级部门  05二级   06 三级

                Problem_historic2Manager.Save(his);
                Response.Write("<script>alert('转派成功！');location.href='List_dbj.aspx'</script>");
            }
        }
        catch (Exception ex)
        {

            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
}